package com.explorati.interview.interview.chapterfive;

import java.util.Comparator;

public class User {

	private String id;
	private int age;

	public User(String id, int age) {
		this.id = id;
		this.age = age;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public static void main(String[] args) {
		ComparableUser user1 = new ComparableUser("u1001", 25);
		ComparableUser user2 = new ComparableUser("u1002", 20);
		Comparator<ComparableUser> comp = new UserComparator();
		int res = comp.compare(user1, user2);
		if (res > 0) {
			System.out.println("用户1大于用户2");
		} else if (res < 0) {
			System.out.println("用户1小于用户2");
		} else {
			System.out.println("用户1等于用户2");
		}
	}
}
